/**
 * @author YinHang
 */
;(function () {
	var Image = GameFramework.inherit("ui.g2d.Displayable")(function (src) {
		this.src = src;
		this.source = new window.Image();
		this.loaded = false;
		this.setVisible(true);
		this.setX(0);
		this.setY(0);
	});
	
	Image.prototype.load = function (callback) {
		var host = this;
		this.source.onload = function () {
			host.setWidth(host.source.width);
			host.setHeight(host.source.height);
			host.loaded = true;
			if(callback)
				callback();
		};
		this.source.src = this.src;
	};
	
	Image.prototype.draw = function (graphics) {
		graphics.drawImage(this, this.x, this.y, this.width, this.height);
	};
	
	GameFramework.register(Image);
})();
